#include "danzai.h"
#include"config.h"

DanZai::DanZai()
{
   //初始化加载蛋仔
    m_danzai.load(DANZAI_PATH);
    //蛋仔坐标
    m_X=0;
    m_Y=0;
    //蛋仔状态
    m_Free=true;
    //蛋仔速度
    m_Speed=DANZAI_SPEED;
    //蛋仔边框
    m_Rect.setWidth(m_danzai.width());
    m_Rect.setHeight(m_danzai.height());
    m_Rect.moveTo(m_X,m_Y);
}

void DanZai::updatePosition()
{
    //空闲的蛋仔
    if(m_Free)
    {
        return;
    }
    //非空闲的蛋仔
    m_X-=m_Speed;
    m_Rect.moveTo(m_X,m_Y);
    if(m_X<=-m_Rect.width())
    {
        m_Free=true;
    }
}
